import { EmployeeModelPermissionPK } from "./employee";
import { OrganizationRolePK } from "./employee-organization-role";
import { GroupModelPermissionPK } from "./group";
import { LevelModelPermissionPK } from "./level";
import { OrganizationModelPermissionPK } from "./organization";
import { RoleModelPermissionPK } from "./role";


export interface Sparrow {
}

export enum HttpMethod {
    GET = "GET",
    POST = "POST",
    PUT = "PUT",
    PATCH = "PATCH",
    DELETE = "DELETE"
}

export enum PermissionEnum {
    READER = "读者",
    AUTHOR = "作者",
    EDITOR = "编辑者",
    DELETER = "删除者",
    DOWNLOAD = "下载",
    FORWARD = "转发",
    SHARE_READER = "授权读者",
    SHARE_AUTHOR = "授权作者",
    SHARE_EDITOR = "授权编辑者",
    SHARE_DELETER = "授权删除者",
    SHARE_FORWARD = "授权转发",
    SHARE_DOWNLOAD = "授权下载",
    ALL_CRUD = "所有操作",
    SHARE_ALL = "所有授权",
    ALL = "所有",
}

export enum OrganizationTypeEnum{
    ORGANIZATION = "组织",
    UNIT = "部门"
}

export class AbstractModelPermissionPK{
  modelName?: string;
  permission?: string;
  permissionType?: string;
}


export interface PageableResponse{
  page: Page;
  _embedded: any,
  _links: {self:{href:string}}
}

export interface Page{
  number?: number,
  size?: number,
  totalElements?: number,
  totalPages?: number,
}

export interface Role extends SparrowEntity{
    code?:string,
    name?:string,
    stat?:string,
    root?: boolean,
    parentIds?: OrganizationRolePK[],
    organizationIds?: string[],


}

export interface Employee extends SparrowEntity{
    username?:string,
    code?:string,
    name?:string,
    stat?:string,
    root?: boolean,
    parentIds?: string[],
    organizationId?:string;
    organizationRoles?:any[];

}

export interface EmployeeOrganizationLevel{
  id: EmployeeOrganizationLevelPK;
  stat: string;
}

export interface OrganizationLevelPK{
  organizationId: string;
  positionLevelId: string;
}

export interface EmployeeOrganizationLevelPK{
  organizationLevelId: OrganizationLevelPK;
  employeeId: string;
}

export interface EmployeeRelationPK{
    employeeId: string;
    parentId:string;
}

export interface EmployeeRelation{
    id:EmployeeRelationPK
}

export interface RoleRelationPK{
    roleId: string;
    parentId:string;
}

export interface RoleRelation{
    id:RoleRelationPK
}

export interface UserSysrole{
  id: UserSysrolePK;
}

export interface UserSysrolePK{
    username: string;
    sysroleId: string;
}

export class SysrolePermission{
    userSysrolePKs: UserSysrolePK[] = [];
}

export interface AbstractDataPermissionPK extends AbstractModelPermissionPK{
    dataId: string;
}

export interface UserDataPermissionPK extends AbstractDataPermissionPK{
    username: string;
}

export interface SysroleDataPermissionPK extends AbstractDataPermissionPK{
    sysroleId: string;
}

export class DataPermission {
    userDataPermissionPKs: UserDataPermissionPK[] = [];
    sysroleDataPermissionPKs: SysroleDataPermissionPK[] = [];
}

export interface Pageable {
    page: number;
    size: number;
    sort?: string[] | undefined;
}

export interface Links{
  _links: any;
}

export interface Sysrole extends Links{
    name: string;
    code: string;
    isSystem?: boolean;
}

export enum UrlPermissionEnum {
    DENY = "DENY",
    ANONYMOUS = "ANONYMOUS",
    AUTHENTICATED = "AUTHENTICATED",
    RESTRICT = "RESTRICT"
}

export interface SparrowEntity extends OperationLog {
    id?: string;
}

export interface SysroleModelPermissionPK {
    modelName: string;
    permission: string;
    permissionType: string;
    sysroleId: string;
}

export interface ModelPermission {
    employeeModelPermissionPKs?: EmployeeModelPermissionPK[];
    sysroleModelPermissionPKs?: SysroleModelPermissionPK[];
    groupModelPermissionPKs?: GroupModelPermissionPK[];
    organizationModelPermissionPKs?: OrganizationModelPermissionPK[];
    roleModelPermissionPKs?: RoleModelPermissionPK[];
    levelModelPermissionPKs?: LevelModelPermissionPK[];
}

export interface OperationLog {
    createdBy?: string;
    createdDate?: Date;
    modifiedBy?: string;
    modifiedDate?: Date;
}

export interface Organization extends SparrowEntity {
    childCount?: number;
    roleCount?: number;
    code: string;
    name: string;
    stat: string;
    type: string;
    parentIds?: string[];
    modelName?: string;
    isRoot?: boolean;
}

export interface OrganizationRelation extends OperationLog {
    id: OrganizationRelationPK
}

export interface OrganizationRelationPK{
  organizationId: string;
  parentId: string;
}

export interface SparrowUrl extends SparrowEntity {
    name: string;
    uri: string;
    method: string;
    permission: string;
    clientId: string;
    system: boolean;
}

export interface Sysrole extends OperationLog {
    id: string;
    name: string;
    code: string;
    system: boolean;
}

export interface Model extends OperationLog {
    name: string;
    nameTxt: string;
    remark?: string;
    appId?: string;
}

export interface ModelAttributePK {
    attributeName: string;
    modelName: string;
}

export interface ModelAttribute extends OperationLog {

    id: ModelAttributePK;
    type: string;
    nameTxt: string;
    remark: string;
}

export class SysroleUrlPermissionPK {
    sysroleId!: string;
    urlId!: string;
    public SysroleUrlPermissionPK(urlId: string, sysroleId: string) {
        this.urlId = urlId;
        this.sysroleId = sysroleId;
    }
}

export interface SysroleUrlPermission extends OperationLog {
    id: SysroleUrlPermissionPK;
    sparrowUrl: SparrowUrl;
    sysrole: Sysrole;
}

